package org.anjan.dp.abstractfactory.shipbuilding;

import org.anjan.dp.abstractfactory.Ship;
import org.anjan.dp.abstractfactory.ShipBuilder;
import org.anjan.dp.abstractfactory.ShipFactory;
import org.anjan.dp.abstractfactory.shipfactoryimpl.DieselShipFactory;
import org.anjan.dp.abstractfactory.shipfactoryimpl.PetrolShipFactory;
import org.anjan.dp.abstractfactory.shipimpl.DieselShip;
import org.anjan.dp.abstractfactory.shipimpl.PetrolShip;

/*
* This is the only class which needs to change, if you want to
* determine which ships you want to provide as an option to build.
* If you want to add a new option to build a new type of ship, it would
* have to be mentioned here.
* */

public class SailShipBuilder extends ShipBuilder {
    @Override
    protected Ship makeShip(String shipType) {
        Ship ship = null;
        if (shipType.equals("Diesel")) {
            ShipFactory factory = new DieselShipFactory();
            ship = new DieselShip(factory);
            ship.setName("Diesel Ship");
        } else if (shipType.equals("Petrol")) {
            ShipFactory factory = new PetrolShipFactory();
            ship = new PetrolShip(factory);
            ship.setName("Petrol Ship");
        }
        return ship;
    }
}
